package com.wyvoid.forum.dao.hibernate;

import com.wyvoid.forum.dao.IFavoriteDAO;
import com.wyvoid.forum.domain.Favorite;
import com.wyvoid.core.persistent.hibernate.HibernateDAO;
import com.wyvoid.core.persistent.hibernate.HibernatePage;
import com.wyvoid.core.persistent.Pagination;

/**
 * 帮助信息Hibernate数据处理实现
 *
 * @author wyvoid
 * @version $Revision: 1.3 $ $Date: 2006/07/11 16:42:21 $
 * @link www.wyvoid.com
 */
public class FavortieDAO extends HibernateDAO<Favorite> implements IFavoriteDAO {
    /**
     * 查找全部的收藏信息
     *
     * @param userId     用户编号
     * @param pagination 分页对象
     * @return List 收藏集合
     */
    public HibernatePage<Favorite> findFavorites(int userId, final Pagination pagination) {
        String hql = getFromHql() + " where userId=?";
        return doQuery(hql, true, pagination, userId);
    }

    /**
     * 清空用户收藏夹
     *
     * @param userId 用户编号
     */
    public void clearUserFavorte(int userId) {
        super.executeHsql("delete from Favorite where userId=?", userId);
    }
}